package com.tn.dao;

import com.googlecode.objectify.Key;
import com.googlecode.objectify.Objectify;
import com.tn.bo.Attachment;
import com.tn.service.OfyDataService;

public class AttachmentDAO {
	
	static {
		// Register All Entities Here.
		OfyDataService.getInstance().registerEntity(Attachment.class);
		
	}
	
	public Attachment insert(Attachment attachment){
		Objectify txn = OfyDataService.getInstance().beginOfyTransaction();
		txn.put(attachment);
		OfyDataService.getInstance().commitOfyTransaction(txn);
		return attachment;
	}
	
	public Attachment find(Long id){
		Objectify ofy = OfyDataService.getInstance().getOfyService();
		return ofy.get(new Key<Attachment>(Attachment.class,id));
	}
}
